/*
 * @(#)UserKeywordRepositoryTest.java $version 2012. 5. 11.
 *
 */

package com.mywep.myalimi.repository.keyword;

import static org.junit.Assert.*;

import java.util.Calendar;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.mywep.myalimi.model.UserKeyword;

import com.nhncorp.lucy.spring.core.util.DataMap;

/**
 * @author 한지웅
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class UserKeywordRepositoryTest {
	@Autowired
	private UserKeywordRepository userKeywordRepository;

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * Test method for {@link com.mywep.myalimi.repository.keyword.UserKeywordRepository#countByExample(com.nhncorp.lucy.spring.core.util.ExtendedMap)}.
	 */
	@Test
	public void testCountByExample() {
		DataMap param = new DataMap();
		int result = userKeywordRepository.countByExample(param);
		assertTrue(result >= 1);
	}

	/**
	 * Test method for {@link com.mywep.myalimi.repository.keyword.UserKeywordRepository#selectByExample(com.nhncorp.lucy.spring.core.util.ExtendedMap)}.
	 */
	@Test
	public void testSelectByExample() {
		DataMap param = new DataMap();
		param.put("id", "banhju");
		param.put("keyword", "웅진에너지");
		List<UserKeyword> userKeywords = userKeywordRepository.selectByExample(param);
		assertEquals(userKeywords.size(), 1);
		assertEquals(userKeywords.get(0).getKeyword(), "웅진에너지");
	}

	/**
	 * Test method for {@link com.mywep.myalimi.repository.keyword.UserKeywordRepository#selectByPrimaryKey(com.mywep.myalimi.model.UserKeyword)}.
	 */
	@Test
	public void testSelectByPrimaryKey() {
		UserKeyword param = new UserKeyword();
		param.setId("banhju");
		param.setKeyword("웅진에너지");
		UserKeyword keyword = userKeywordRepository.selectByPrimaryKey(param);
		assertEquals(param.getKeyword(), "웅진에너지");
	}

	/**
	 * Test method for {@link com.mywep.myalimi.repository.keyword.UserKeywordRepository#insert(com.mywep.myalimi.model.UserKeyword)}.
	 */
	@Test
	public void testInsert() {
		UserKeyword param = new UserKeyword();
		param.setKeyword("test");
		param.setId("banhju");
		param.setRegDate(Calendar.getInstance().getTime());
		userKeywordRepository.insert(param);
		//		assertTrue(result > 0);
	}

}
